package com.weareint.examples.dto;

import com.weareint.examples.entity.Material;
import com.weareint.common.dto.AbstractDTO;
import com.weareint.common.dto.IBasicDTO;
import com.weareint.common.utils.DateUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 *
 *
 * <pre>
 *      物料DTO
 * </pre>
 *
 * @author Auto Generator
 * @date 2021-07-16
 */
@ApiModel(value = "物料", description = "物料")
@Data
@EqualsAndHashCode(callSuper = true)
public class MaterialDTO extends AbstractDTO implements IBasicDTO<Material> {

    @ApiModelProperty(value = "物料名称")
    private String name;

    @ApiModelProperty(value = "物料编码")
    private String code;

    @ApiModelProperty(value = "物料描述")
    private String description;

    @ApiModelProperty(value = "库位")
    private String storageLocation;

    @ApiModelProperty(value = "货位")
    private String storageDetailLocation;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "供应商ID")
    private Long supplierId;

    @ApiModelProperty(value = "硅片厚度")
    private String thickness;

    @ApiModelProperty(value = "硅片类型：L表示单晶，N表示多晶")
    private String type;

    @ApiModelProperty(value = "")
    private String crystal;

    @ApiModelProperty(value = "")
    private String bonded;

    @ApiModelProperty(value = "")
    private String grideLine;


    /**
     * <pre>
     *     转化为Entity对象
     * </pre>
     * @return {@link Material}
     */
    @Override
    public Material toEntity() {
        Material entity = new Material();
        entity.setId(this.getId());
        entity.setName(this.getName());
        entity.setCode(this.getCode());
        entity.setDescription(this.getDescription());
        entity.setStorageLocation(this.getStorageLocation());
        entity.setStorageDetailLocation(this.getStorageDetailLocation());
        entity.setRemark(this.getRemark());
        entity.setSupplierId(this.getSupplierId());
        entity.setThickness(this.getThickness());
        entity.setType(this.getType());
        entity.setCrystal(this.getCrystal());
        entity.setBonded(this.getBonded());
        entity.setGrideLine(this.getGrideLine());
        return entity;
    }

    /**
     * <pre>
     *     依据非空的属性创建一个新Entity
     * </pre>
     * @return {@link Material}
     */
    @Override
    public Material toNewEntityIgnoreNulls() {
        Material unPersistentEntity = new Material();
        toEntityIgnoreNulls(unPersistentEntity);
        return unPersistentEntity;
    }

    /**
     * <pre>
     *     把非空的属性复制到已有的实体上
     * </pre>
     * @param persistentEntity {@link Material}
     */
    @Override
    public void toEntityIgnoreNulls(Material persistentEntity) {
        if (null != this.getCreateTime()){
            persistentEntity.setCreateTime(DateUtil.parse(this.getCreateTime()));
        }
        if (null != this.getUpdateTime()){
            persistentEntity.setUpdateTime(DateUtil.parse(this.getUpdateTime()));
        }
        if (null != this.getCreator()){
            persistentEntity.setCreator(this.getCreator());
        }
        if (null != this.getUpdater()){
            persistentEntity.setUpdater(this.getUpdater());
        }
        if (null != this.getId()){
            persistentEntity.setId(this.getId());
        }
        if (null != this.getName()){
            persistentEntity.setName(this.getName());
        }
        if (null != this.getCode()){
            persistentEntity.setCode(this.getCode());
        }
        if (null != this.getDescription()){
            persistentEntity.setDescription(this.getDescription());
        }
        if (null != this.getStorageLocation()){
            persistentEntity.setStorageLocation(this.getStorageLocation());
        }
        if (null != this.getStorageDetailLocation()){
            persistentEntity.setStorageDetailLocation(this.getStorageDetailLocation());
        }
        if (null != this.getRemark()){
            persistentEntity.setRemark(this.getRemark());
        }
        if (null != this.getSupplierId()){
            persistentEntity.setSupplierId(this.getSupplierId());
        }
        if (null != this.getThickness()){
            persistentEntity.setThickness(this.getThickness());
        }
        if (null != this.getType()){
            persistentEntity.setType(this.getType());
        }
        if (null != this.getCrystal()){
            persistentEntity.setCrystal(this.getCrystal());
        }
        if (null != this.getBonded()){
            persistentEntity.setBonded(this.getBonded());
        }
        if (null != this.getGrideLine()){
            persistentEntity.setGrideLine(this.getGrideLine());
        }
    }


}
